﻿#region Using Directives

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Reflection;

using Microsoft.SharePoint;

#endregion Using Directives

namespace SharePointStu.SharePoint.General.Helpers
{
    /// <summary>
    /// General helper class
    /// </summary>
    public sealed class Common
    {
        #region Private Members

        private static readonly Regex isGuid = new Regex(@"^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$", RegexOptions.Compiled);

        #endregion Private Members

        #region Public Methods

        /// <summary>
        /// Get if the candidate string is a valid Guid.
        /// </summary>
        /// <param name="candidate">Candidate string to validate as a Guid.</param>
        /// <returns>If the candidate string is a Guid.</returns>
        public static bool IsGuid(string candidate)
        {
            return isGuid.IsMatch(candidate);
        }

        #endregion Public Methods
    }
}
